package com.zeratul.common.strategy.config;

import com.zeratul.common.strategy.aspect.StrategyAspect;
import com.zeratul.common.strategy.event.RefreshEventListener;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@Configuration
@Slf4j
@EnableAspectJAutoProxy
public class StrategyAutoConfiguration {

    /**
     * 策略切面
     * @return
     */
    @Bean
    public StrategyAspect getStrategyAspect(){
        log.debug("【策略组件】策略组件加载...");
        return new StrategyAspect();
    }

    /**
     * 配置刷新监听器
     */
    @Bean
    @ConditionalOnClass(name = "org.springframework.cloud.endpoint.event.RefreshEvent")
    public RefreshEventListener getRefreshEventListener(){
        log.debug("【策略组件】配置刷新监听器加载...");
        return new RefreshEventListener();
    }
}
